package cn.francis.controller;

import cn.francis.service.UserService;
import com.qfedu.agro.common.ResultInfo;
import com.qfedu.agro.util.JwtUtil;
import com.qfedu.agro.vo.SysUserVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Name: UserController
 * Package: cn.francis.controller
 * Date: 2024/10/24 - 09:43
 * Description:
 *
 * @author Junhui Zhang
 * @version v1.0
 */

@RestController
@RequestMapping("/sys/user")
@CrossOrigin
@Slf4j
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public ResultInfo login(@RequestBody SysUserVo sysUserVo) {
        // TODO 校验
        return userService.login(sysUserVo.getUsername(), sysUserVo.getPassword());
    }

    @PostMapping("/logout")
    public ResultInfo logout() {
        return userService.logout();
    }
}
